const express = require("express");
const router = express.Router();
const useApiRes = require('../common/apiRes')

// 获取HTML
router.get("/speak", (req, res) => {
    const params = req.query;
    try {
        if (!params.text) {
            throw new Error('请输入要播报的文字');
        }
        if (!global.MAIN_WINDOW) {
            throw new Error('请先打开主窗口');
        }
        global.MAIN_WINDOW.webContents.send('tts:render:speak', params);
        return useApiRes.success(res, '播报成功');
    } catch (error) {
        return useApiRes.fail(res, error.message);
    }
});
module.exports = router;